package top.yuki.event;

import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import top.yuki.LevelWorld;
import top.yuki.data.DataManager;
import top.yuki.data.DayDataManager;
import top.yuki.data.TempDataManage;
import top.yuki.data.WorldManage;

public class onMobDamage implements Listener {
    public DataManager dataManage;
    private final TempDataManage tempDataManage;
    private final DayDataManager dayDataManager;
    private final WorldManage worldManage;
    private final ConfigurationSection config;
    public onMobDamage (LevelWorld lw){
        this.dataManage = LevelWorld.dataManage;
        this.tempDataManage = LevelWorld.tempDataManage;
        this.dayDataManager = LevelWorld.dayDataManager;
        this.worldManage = LevelWorld.worldManage;
        this.config = lw.getConfig();
    }
    @EventHandler
    public void mobDamage(EntityDamageByEntityEvent event){
        if (!(event.getEntity() instanceof Player)){return;}
        double damage = event.getDamage();
        World world = event.getEntity().getLocation().getWorld();
        int worldLevel = worldManage.getWorldLevel(world.getName());
        double worldMobAttackMagnification = Double.valueOf(String.valueOf(config.get("worldMobAttackMagnification." + worldLevel)));
        event.setDamage(damage*worldMobAttackMagnification);

    }

}
